﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

namespace IndyMosaic.Core.Extensions
{
    public static class MembershipExtensions
    {
        public static Guid GetUserIDAsGuid(this MembershipUser user)
        {
            Guid userID = Guid.Empty;
            if (user != null)
            {
                userID = (Guid)user.ProviderUserKey;
            }
            return userID;
        }

        public static bool IsCommentApprover(this MembershipUser user)
        {
            if (user == null)
            {
                return false;
            }
            bool isApprover = false;
            string[] approverRoles = {"Administrator", "Content Provider"};
            string[] userRoles = Roles.GetRolesForUser(user.UserName);

            foreach (string roleName in approverRoles)
            {
                if (userRoles.Contains(roleName))
                {
                    isApprover = true;
                }
            }
            return isApprover;
        }
    }
}
